<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title>添加会员</title>
<link rel="shortcut icon" href="favicon.ico">
<link href="css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
<link href="css/plugins/iCheck/custom.css" rel="stylesheet">
<link href="css/plugins/chosen/chosen.css" rel="stylesheet">
<link href="css/plugins/colorpicker/css/bootstrap-colorpicker.min.css"
	rel="stylesheet">
<link href="css/plugins/cropper/cropper.min.css" rel="stylesheet">
<link href="css/plugins/switchery/switchery.css" rel="stylesheet">
<link href="css/plugins/jasny/jasny-bootstrap.min.css" rel="stylesheet">
<link href="css/plugins/nouslider/jquery.nouislider.css"
	rel="stylesheet">
<link href="css/plugins/datapicker/datepicker3.css" rel="stylesheet">
<link href="css/plugins/ionRangeSlider/ion.rangeSlider.css"
	rel="stylesheet">
<link href="css/plugins/ionRangeSlider/ion.rangeSlider.skinFlat.css"
	rel="stylesheet">
<link
	href="css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css"
	rel="stylesheet">
<link href="css/plugins/clockpicker/clockpicker.css" rel="stylesheet">
<link href="css/animate.min.css" rel="stylesheet">
<link href="css/style.min862f.css?v=4.1.0" rel="stylesheet">
</head>

<body class="gray-bg">
	<div class="wrapper wrapper-content animated fadeInRight">
		<div class="form-group">
			<label class="col-sm-2 control-label">员工姓名</label>
			<div class="col-sm-10">
			<input id="userId" type="hidden"/>
				<input type="text" class="form-control" id="Empname">
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-2 control-label">登陆名</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" id="Account">
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-2 control-label">手机号码</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" id="Empphone">
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group draggable">
			<label class="col-sm-2 control-label">性别 </label>
			<div class="col-sm-10">
				<div class="radio radio-info radio-inline">
					<input type="radio" checked="" value="1" id="inlineRadio1"
						name="radioInline"> <label for="inlineRadio1">男</label>
				</div>
				<div class="radio radio-info radio-inline">
					<input type="radio" value="2" id="inlineRadio2" name="radioInline">
					<label for="inlineRadio2">女</label>
				</div>
			</div>
		</div>

		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-2 control-label">住址</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" id="Empaddr">
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-2 control-label">登录密码</label>
			<div class="col-sm-10">
				<input type="text" class="form-control" id="Emppwd">
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<div class="col-sm-4 col-sm-offset-2">
				<input class="btn btn-white" type="button" value="保存" id="updateSave1">
				<button class="btn btn-white" onclick="javascript:history.back(-1);">取消</button>
			</div>
		</div>

	</div>

	<script src="js/jquery.min.js?v=2.1.4"></script>
	<script src="js/bootstrap.min.js?v=3.3.6"></script>
	<script>
	function selectById(id) {

		$.ajax({
			type : "POST", // 请求方式
			url : "sysuser/queryOne?id=" + id, // 请求路径
			headers : {
				'content-Type' : 'application/json'
			},
			dataType : 'json',
			success : function(data) {
				if (data.httpCode == "200") {
					createDataForUpdate(data.data)
				} else {
					// alert("登录失败");
					showmessage01('登录失败!');
				}
			},
			error : function() {
				alert("errr");
			}
		});

	}
	function createDataForUpdate(data) {
		$("#userId").val(data.id);
		$("#Empname").val(data.name);
		$("#Account").val(data.account);
		$("#Empphone").val(data.phone);
		$("#Empaddr").val(data.address);
		$("#Emppwd").val(data.password);

		$("input[name='radioInline']").each(function(index, element) {

			if ($(this).val() == data.sex) {
				$(this).prop("checked", true);
			}
		});
	}
	$(document).ready(function(){
		 var url = location.search;
		   if (url.indexOf("?") != -1) {
		      var str = url.substr(1);
		      strs = str.split("=");  
		      selectById(strs[1]);
		   }
		$("#updateSave1").click(function(){
			var id = $("#userId").val();
			var Empname = $("#Empname").val();
			var Account = $("#Account").val();
			var sex = $('input:radio:checked').val();
			var Empphone = $("#Empphone").val();
			var Empaddr = $("#Empaddr").val();
			var Emppwd = $("#Emppwd").val();
			var data = {
					"id":id,
				"account":Account,
				"name" : Empname,
				"sex" : sex,
				"phone" : Empphone,
				"address" : Empaddr,
				"password" : Emppwd
			};
			$.ajax({
				type : "POST", // 请求方式
				url : "sysuser/updateUser", // 请求路径
				headers : {
					'content-Type' : 'application/json'
				},
				dataType : 'json',
				data : JSON.stringify(data),
				success : function(data) {
					console.log(data);
					if (data.httpCode == "200") {
						console.log(data.data);
						window.location.href='settingEmp.html';
					} else {
						// alert("登录失败");
						showmessage01('登录失败!');
					}
				},
				error : function() {
					alert("errr");
				}
			});
		})
		
	})
	</script>
</body>

</html>